package com.Test;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;

public class Test25 {
    public static void main(String[] args) {
        // 获取当月的最后一天
        LocalDate today = LocalDate.now();

        // 获取3个月之前的第一天
        LocalDate firstDayOfThreeMonthsAgo = today.minusMonths(2).with(TemporalAdjusters.firstDayOfMonth());
        String firstDayOfThreeMonthsAgoStr = firstDayOfThreeMonthsAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        String startDate = firstDayOfThreeMonthsAgoStr + " 00:00:00";
        System.out.println("开始日期: " + startDate);

        LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth());
        String lastDayOfMonthStr = lastDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        String endDate = lastDayOfMonthStr + " 23:59:59";
        System.out.println("结束日期: " + endDate);
    }
}
